<?php
class PublicAction extends BaseAction{
    public function menu(){
        $this->display();
    }
    public function main(){
        $this->display();
    }
    public function drag(){
        $this->display();
    }
    public function top(){
        $this->display();
    }
    public function header(){
    	  $this->display();
    }
    public function footer(){
        $this->display();
    }
    public function login(){
    		$this->display();	
    }
    public function doLogin(){
    	//判断验证码
    	if($_SESSION['verify'] != md5($_POST['verify'])) {   
				$this->error('验证码错误！');   
	  	}
    	$userModel = M('Admin');
			$user = $userModel->where('account="'.$_POST['account'].'" AND password="'.md5($_POST['password']).'"')->find();		  
			if($user){
	    	$_SESSION['adminId'] = $user['id'];
				$_SESSION['account'] = $user['account'];
				$_SESSION['eip'] = $user['eip'];
				$_SESSION['etime'] = date("Y-m-d H:i:s",$user['etime']);
				Load('extend'); //加载函数库
				$data['id'] = $user['id'];
				$data['eip'] = get_client_ip();
				$data['etime'] = time();
				$result = $userModel->save($data);
				$this->assign("list",$user);
				$this->redirect('Index/index');
			}else{
				$this->error('用户名或密码错误！');
			}
    }
    public function logout(){
    	  $_SESSION['adminId'] = null;
				$_SESSION['account'] = null;
    	  Session::destroy();
        
        $this->assign("jumpUrl",__APP__.'/Public/login/');
        $this->success('登出成功!!!');
    }
    
		public function verify(){
    	import("ORG.Util.Image");   
			image::buildImageVerify(5,3);
    }    
}
?>